//
//  FadeOutAnimationController.swift
//  StoreSearch
//
//  Created by cygarm on 15/12/28.
//  Copyright © 2015年 cygarm. All rights reserved.
//

import Foundation
import UIKit

class FadeOutAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
	func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
		return 0.4
	}
	
	func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
		if let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey) {
			let duration = transitionDuration(transitionContext)
			UIView.animateWithDuration(duration, animations: { () -> Void in
				fromView.alpha = 0
				}, completion: { (finished) -> Void in
					transitionContext.completeTransition(true)
			})
		}
	}
}